<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$this->model('model')->check_worker();
if($_RQ['op']=='get'){
	$data=array();
	$data['fee']=pdo_getsum('jy_weishop_order',array('ispay'=>1,'uniacid'=>$_SESSION['uniacid']),'price');
	$data['num']=pdo_count('jy_weishop_order',array('ispay'=>1,'uniacid'=>$_SESSION['uniacid']));
	$return['data']=$data;
	$return['params']=array('type'=>0);
	set_html('title','销量账单');
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$params=array('ispay'=>1,'uniacid'=>$_SESSION['uniacid']);
	$page=intval($_RQ['page']);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 12;
	$total='';
	$list=array();
	$page=$page-1;
	if($page){
		$ytime=strtotime('-'.$page.' year');
		$addmonth=12*$page;
		$ylasttime=time()-$ytime;
	}else{
		$ylasttime=0;
		$addmonth=0;
	}
	for($i=0;$i<12;$i++){
			if($i==0){
				$yuestart = mktime(0,0,0,date('m'),1,date('Y'))-$ylasttime;
				$yueend = time()-$ylasttime;
			}else{
				$yuestart = mktime(0,0,0,date('m')-$i,1,date('Y'))-$ylasttime;
				$yueend = mktime(0,0,0,date('m')-$i+1,1,date('Y'))-$ylasttime;
			}
			$params['createtime between']=array($yuestart,$yueend);
			$nowmonth=$addmonth+$i;
			$month = date('Y-m',strtotime('-'.$nowmonth.' month'));
			$num=pdo_count('jy_weishop_order',$params);
			$fee=pdo_getsum('jy_weishop_order',$params,'price');
			$list[]=array(
				'month'=>$month,
				'num'=>$num,
				'fee'=>$fee,
			);
	}
	$return['list']=$list;
	exi($return);
}